package com.asc.mywriter.controller;

import com.asc.mywriter.bean.ProOrder;
import com.asc.mywriter.serciceImpl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
public class OrderController {
    @Autowired
    OrderServiceImpl orderService;

    @ResponseBody
    @PostMapping("/saveOrder")
    public Map<String,Object> saveOrder(@RequestParam("proId") Integer proId, HttpSession session){
        Map<String,Object> map = new HashMap<String,Object>();
        String userId = session.getAttribute("userId").toString();
        orderService.saveOrder(Integer.valueOf(userId),proId);
        map.put("msg","购买成功!");
        return map;
    }

}
